let age1: number = 18;

let myName: string = 'zs';

let isLoading: boolean = true;

let a: null = null;

let b: undefined = undefined;

let c: symbol = Symbol();

let arr: number[] = [1, 2, 3, 4]

let arr1: Array<string> = ['a', 'b', 'c']

// 联合类型
let arr2: (number | string)[] = [1, 'a', 2, 'b']
// 不添加小括号的话，就是或的关系，既可以是数值型，又可以是字符串数组
// let arr2: number | string[] = 123
// let arr2: number | string[] = ['1','2']

// 类型别名
type CustomArray = (number | string)[];
let arr3: CustomArray = [1, 2, 4, 'a']

// 函数类型
// 同时指定类型和返回值
const add: (num1: number, num2: number) => number = (num1, num2) => {
  return num1 + num2
}

// 函数没有返回值的时候返回void
function greet(name: string): void {
  console.log(name)
}